package com.xdclass.intertupt;

/**
 * @Author: Timo
 * @Date: 2019/4/26 12:12
 * @Description: 模拟调用stop()产生的线程安全性的问题
 */
public class UnSafeWithStop extends Thread{
    private int i = 0 ;
    private int j = 0 ;

    @Override
    public void run() {
        i++;
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        j++;
    }

    private void printf() {
        System.out.println("i==================>"+i);
        System.out.println("j==================>"+j);
    }

    public static void main(String[] args) throws InterruptedException {
        UnSafeWithStop unSafeWithStop = new UnSafeWithStop();

        unSafeWithStop.start();
        Thread.sleep(1000L);
        unSafeWithStop.stop();
        unSafeWithStop.printf();

    }
}
